-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added temporary voice messages #1874
Conversation
c44beda
to
dd3e20b
Compare
I am not sure why the localizable change is not passing the test? :/ |
Interesting, seems to be a sorting issue. I’ll take a look. |
So I tried multiple things yesterday and it only happens if you rebase on master (that is what CI does and that's why you can't seem to trigger that change locally in your branch). I have the same issue in #1880. I couldn't fully figure out what's triggering this, even rebasing on old commits did not change that. So for now I'd say we ignore it and take a look later when the PR is merged. We are going to have a closer look to this and your other PR this week :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked through everything, here are some first comments :)
|
||
let referenceId = "temp-\(Date().timeIntervalSince1970 * 1000)" | ||
temporaryMessage.referenceId = NCUtils.sha1(fromString: referenceId) | ||
temporaryMessage.internalId = referenceId | ||
temporaryMessage.isTemporary = true | ||
temporaryMessage.isOfflineMessage = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isOfflineMessage
indicates that this message was sent without an internet connection and should be resend, when connection is available again. So this shouldn't be added here.
There's quite some logic involved (including trying to resend in the background). Check out e.g.
talk-ios/NextcloudTalk/NCChatController.m
Line 685 in dd3e20b
- (void)sendChatMessage:(NSString *)message replyTo:(NSInteger)replyTo referenceId:(NSString *)referenceId silently:(BOOL)silently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the information, I recognized that the context menu fits better when using the isOfflineMessage = true. That's why I set it to true.
For example the "open in nextcloud" (shouldn't really be an option), "copy" and "create reminder" option dont work out of the box.
I removed it now, should we fix some of the options like "delete" then or hide some of the invalid options?
"fileLocalPath": messageParameters | ||
] | ||
|
||
messageParametersDict[parameterId] = fileParameterDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using a UUID here? Should it be the file dictionary? I don't see it used anywhere? (Maybe I missed it, not yet through everything).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I guess I had a problem with the file parameter not being set when putting the fileParameters in no dictionary.
What's your suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use "file" as the key here
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
dd3e20b
to
c7ef13c
Compare
Hey Daniel, left you a message about this PR on our instance :) |
@@ -1590,52 +1634,83 @@ import QuickLook | |||
audioFileName += ".mp3" | |||
|
|||
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount() | |||
NCAPIController.sharedInstance().setupNCCommunication(for: activeAccount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason to setup the communication here? Because in uniqueNameForFileUploadWithName
there's already a setup call and I don't think it's needed before that call.
isVoiceMessage: true | ||
) | ||
|
||
chatFileController.setFileStatusFrom(temporaryMessage.file()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not using the chatFileController
in this method again (besides moving the file), we don't need the filestatus to be set.
chatFileController.setFileStatusFrom(temporaryMessage.file()) | ||
|
||
let movedFileToTemporaryDirectory = chatFileController.moveFileToTemporaryDirectory( | ||
fromSourcePath: self.recorder!.url.path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use something like guard let recorder = self.recorder else { return }
at the beginning of the file, so we don't have to force-unwrap here.
NCAPIController.sharedInstance().uniqueNameForFileUpload(withName: audioFileName, originalName: true, for: activeAccount, withCompletionBlock: { fileServerURL, fileServerPath, _, _ in | ||
if let fileServerURL, let fileServerPath, let recorder = self.recorder { | ||
let talkMetaData: [String: String] = ["messageType": "voice-message"] | ||
self.uploadFileAtPath(localPath: recorder.url.path, withFileServerURL: fileServerURL, andFileServerPath: fileServerPath, withMetaData: talkMetaData) | ||
|
||
self.uploadFileAtPath(localPath: recorder.url.path, withFileServerURL: fileServerURL, andFileServerPath: fileServerPath, withMetaData: talkMetaData, temporaryMessage: temporaryMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.uploadFileAtPath(localPath: recorder.url.path, withFileServerURL: fileServerURL, andFileServerPath: fileServerPath, withMetaData: talkMetaData, temporaryMessage: temporaryMessage) | |
self.uploadFileAtPath(localPath: destinationFilePath, withFileServerURL: fileServerURL, andFileServerPath: fileServerPath, withMetaData: talkMetaData, temporaryMessage: temporaryMessage) |
Otherwise the file is not found on upload (because we moved it before) and we get a 0 byte file.
NextcloudTalk/ChatFileUploader.swift
Outdated
completion(200, nil) | ||
} | ||
} | ||
case 404: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original code, also case 409 was checked here.
NextcloudTalk/NCChatFileController.h
Outdated
|
||
- (void)initDownloadDirectoryForAccount:(TalkAccount *)account; | ||
- (void)setFileStatusFromParameter:(NCMessageFileParameter *)fileParameter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, this is not needed anymore, since we don't call it?!
NextcloudTalk/NCChatFileController.m
Outdated
- (void)setFileStatusFromParameter:(NCMessageFileParameter *)fileParameter { | ||
_fileStatus = [[NCChatFileStatus alloc] initWithFileId:fileParameter.parameterId fileName:fileParameter.name filePath:fileParameter.path fileLocalPath:fileParameter.fileStatus.fileLocalPath]; | ||
fileParameter.fileStatus = _fileStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So also not needed?
NextcloudTalk/NCChatFileController.m
Outdated
NSError *error = nil; | ||
if ([[NSFileManager defaultManager] moveItemAtPath:sourcePath toPath:destinationPath error:&error]) { | ||
NSLog(@"File successfully moved to: %@", destinationPath); | ||
_fileStatus.fileLocalPath = destinationPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the fileStatus is not used, we can remove that line as well
NextcloudTalk/NCChatFileController.m
Outdated
- (bool)moveFileToTemporaryDirectoryFromSourcePath:(NSString *)sourcePath destinationPath:(NSString *)destinationPath { | ||
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount]; | ||
|
||
[[NCAPIController sharedInstance] setupNCCommunicationForAccount:activeAccount]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to setup the communication here, as we only move locally.
"fileLocalPath": messageParameters | ||
] | ||
|
||
messageParametersDict[parameterId] = fileParameterDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use "file" as the key here
365e2c7
to
b1797e5
Compare
related to #1261 Signed-off-by: Daniel Standfest <[email protected]>
c9964ad
to
35aa953
Compare
Signed-off-by: Daniel <[email protected]>
Review implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this PR @DanielStandfest :)
Works nicely now and it's a great enhancement!
Rebase failed
Thanks again @DanielStandfest ! Merged and will be included in the next release :) |
added support for temporary voice messages and handling them just like text messages.
related to #1261
Would be happy to get feedback! :)
Cheers,
Daniel